package servlets;

import interfaces.IServicioProveedor;

import java.io.IOException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dto.DTOProveedor;

public class InputListaDePrecios extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	private IServicioProveedor srvProveedor;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			srvProveedor = (IServicioProveedor)Naming.lookup("//localhost/ServicioProveedor");
			
			Integer codigo = Integer.MIN_VALUE;

			//List<DTOProveedor> data = srvProveedor.listarProveedores(codigo, "");
			
			List<DTOProveedor> data = srvProveedor.listarProveedores(Integer.MIN_VALUE, "");
			
			HttpSession session = request.getSession();
			session.setAttribute("data",data);
			
			response.sendRedirect("importarLista.jsp");
			
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
